package com.totoro.tyrank.executor.action.impl;

import com.totoro.tyrank.constants.ActionConst;
import com.totoro.tyrank.executor.action.ActionExecutor;
import com.totoro.tyrank.utils.PapiUtil;
import com.totoro.tyrank.utils.StrUtil;
import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.Player;

public class ActionBarActionExecutor implements ActionExecutor {
    @Override
    public void execute(String actionText, Player player) {
        actionText = StrUtil.getContentAfter(actionText, ActionConst.ACTION_BAR);
        actionText = PapiUtil.parseStrPapiVariable(player, actionText);
        player.spigot().sendMessage(
                ChatMessageType.ACTION_BAR,
                TextComponent.fromLegacyText(actionText)
        );
    }
}
